package java_thinking.unit_9._9_1;

/**
 * @Description :
 * @author: cww
 * @DateTime: 2019-03-02 15:30
 */

abstract class Initialization {
    abstract void print();

    /**
     * 实例化子类时也会对父抽象类进行初始化，初始化时调用了抽象方法print，
     * 调用子类覆写的方法时此时子类的成员处于准备阶段还未初始化，所以i是0
     */
    Initialization(){
        print();
    }
}

class SunClass extends Initialization{

    private int i = 1;
    @Override
    void print() {
        System.out.println("SunClass.print() i="+i);
    }
}

class TestAbstractInitial{
    public static void main(String[] args) {
        Initialization initialization = new SunClass();
        initialization.print();
    }
}